package com.itheima.d2_threadmethod;


/**
 * Thread类中的常用方法
 */
public class ThreadMethodDemo1 {
    public static void main(String[] args) {
        MyThread mt1 = new MyThread("构造器线程1");
        mt1.start();

        mt1.setName("小酆都线程1");

        MyThread mt2 = new MyThread("构造器线程2");
        mt2.start();
        mt2.setName("小酆都线程2");


        //获取当前线程对象 主线程
        Thread thread = Thread.currentThread();
        System.out.println(thread.getName());
    }
}


class MyThread extends Thread {
    public MyThread(String name) {
        super(name);
    }
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            Thread thread = Thread.currentThread();
            System.out.println(thread.getName() + "正在执行..." + i);
        }
    }
}
